package com.lottery.ruok.lottrey.ui.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.TextView;

public class  OrientationTextView extends AppCompatTextView {

    public OrientationTextView (Context context) {
        super(context);
    }

    public OrientationTextView (Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (getLineCount() > 1) {//得到文本的行数
            setGravity(Gravity.LEFT);
        } else {
            setGravity(Gravity.RIGHT);
        }

        canvas.save();
    }
}